package club.fuwenhao;

import club.fuwenhao.handler.FwhNettyServerHandler;
import club.fuwenhao.netty.BaseNettyServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * @program: fwh-netty
 * @description: 服务端启动类
 * @author: fwh
 * @date: 2021-10-27 17:29
 **/
@Slf4j
@SpringBootApplication
public class FwhNettyServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(FwhNettyServerApplication.class, args);
        log.info("NettyServerApplication is start");
    }

    @Bean
    protected boolean nettyServer() throws InterruptedException {
        boolean start = new BaseNettyServer().setPort(9000).setBaseNettyServerHandler(new FwhNettyServerHandler()).start();
        if (start) {
            log.info("Netty服务端启动成功,端口为:{}", 9000);
        } else {
            log.error("Netty服务端启动失败,端口为:{}", 9000);
        }
        return start;
    }
}
